<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
				xmlns:f="http://java.sun.com/jsf/core"
				xmlns:h="http://java.sun.com/jsf/html"
				xmlns:p="http://primefaces.prime.com.tr/ui"
				xmlns:ui="http://java.sun.com/jsf/facelets"
				xmlns:survey="http://java.sun.com/jsf/composite/components/question"
				template="/layout/template.xhtml">
	
	<ui:define name="body">
	
		<h:form id="questionsListForm">
			
			<p:panel styleClass="panel-text full-size">
				<center>
					<h:outputText value="There is no question registered."
								  rendered="#{empty questionsManagementView.questions}" />
				</center>
				
				<h:dataTable id="questionsList"
							 value="#{questionsManagementView.questions}"
							 var="question"
							 styleClass="dataTableComponent"
							 rendered="#{not empty questionsManagementView.questions}">
					
					<h:column headerClass="dataTablaHeader">
						<f:facet name="header">
							<h:outputText value="ID" />
						</f:facet>
					    <h:outputText value="##{question.id}" />
					</h:column>
					
					<h:column headerClass="dataTablaHeader">
						<f:facet name="header">
							<h:outputText value="Question Text" />
						</f:facet>
					    <h:outputText value="#{question.text}" />
					</h:column>
					
					<h:column headerClass="dataTablaHeader">
						<f:facet name="header">
							<h:outputText value="Creation Date" />
						</f:facet>
					    <h:outputText value="#{question.creationDate}" />
					</h:column>
					
					<h:column headerClass="dataTablaHeader">
						<f:facet name="header">
							<h:outputText value="Level" />
						</f:facet>
					    <h:outputText value="#{question.level}" />
					</h:column>
					
					<h:column>
						<h:commandButton value="Editar" action="#{questionEditorHandler.selectQuestionToEdit(question)}" />
						
						<h:commandButton value="Remove" action="#{questionsManagementView.removeQuestion(question)}">
							<f:ajax event="action" process="@this" render=":questionsListForm :notifications :statisticsPanel:statisticsPanel" />
						</h:commandButton>
					</h:column>

				</h:dataTable>
					
			</p:panel>
	
		</h:form>
	</ui:define>
</ui:composition>